<?php

require 'common.php';
require 'template/header.php';
require 'template/menu.php';

// { page content
echo '<script type="text/javascript" src="j/addressbook.js"></script>';
echo '<script type="text/javascript" src="j/inline-editing.js"></script>';
echo '<div id="page_content">';
echo '<h1>Addressbook</h1>';
echo '<div id="submenu"><a href="javascript:addressbook_entry_form()">Add Address</a></div>';

// { show list of addressbook entries
echo '<table id="addressbook_entries"><tr><th>Name</th><th>Address</th><th>Notes</th>';
// TODO: add custom data fields here
echo '<td>&nbsp;</td></tr>';
$rs=dbAll('select * from addressbook order by name');
foreach($rs as $r){
	echo '<tr id="addressbook_entry_'.$r['id'].'">'
		,'<td class="name">'.htmlspecialchars($r['name']).'</td>'
		,'<td class="address">'.htmlspecialchars($r['address']).'</td>'
		,'<td class="notes">'.htmlspecialchars($r['notes']).'</td>';
	// TODO: add custom data fields here
	echo '<td><a href="javascript:addressbook_entry_delete('.$r['id'].')">[x]</a></td></tr>';
}
echo '</table>';
// }

echo '</div>';
// }

require 'template/footer.php';
